#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include<stdlib.h>
#include<assert.h>



typedef char BTDataType;
typedef struct BinaryTreeNode {
    struct BinaryTreeNode* left;
    struct BinaryTreeNode* right;
    BTDataType data;
} BTNode;

BTNode* BuyNode(BTDataType x);
BTNode* CreateBinaryTree(char* arr, int* pi);


BTNode* BuyNode(BTDataType x) {
    BTNode* newnode = (BTNode*)malloc(sizeof(BTNode));
    assert(newnode);
    newnode->right = NULL;
    newnode->left = NULL;
    newnode->data = x;

    return newnode;
}
BTNode* CreateBinaryTree(char* arr, int* pi) {
    if (arr[(*pi)] == '#') {
        (*pi)++;
        return NULL;
    }
    BTNode* root = BuyNode(arr[(*pi)++]);
    root->left = CreateBinaryTree(arr, pi);
    root->right = CreateBinaryTree(arr, pi);
    return root;
}

void Inorder(BTNode* root) {
    if (root == NULL) {
        return;
    }
    Inorder(root->left);

    printf("%c ", root->data);

    Inorder(root->right);
}





int main() {
    int i = 0;
    char arr[100] = "abc##de#g##f###";
 /*   scanf("%s ", arr);*/
    BTNode* root = CreateBinaryTree(arr, &i);
    Inorder(root);
    return 0;
}